<?php

class Mpages_cat extends CI_Model {
	
	public $table = 'tbl_page_cat';
	public $pri_key="cat_id";
	public $lang_key="cat_lang";


	function __construct()

	{

		parent::__construct();

	}
	
		public function get_prod_detail($id="",$lang,$cate="")
	{
		if($id != "")
			$this->db->where($this->pri_key,$id);
		if($cate != "")
			$this->db->where('page_cat',$cate);
		
		$this->db->where('page_lang',$lang);
			$this->db->order_by($this->pri_key." DESC");
		$query = $this->db->get($this->table);
		if($query->num_rows() >0)
			return $query->row_array();
		return false;
	}
		public function del_item($id)
	{
		//if($id > 4)
		{
		$this->db->where($this->pri_key, $id);
		$this->db->delete($this->table); 
		}
	}
	
	public function insert($data)
	{

		if($this->db->insert($this->table,$data))
			return true;
		
		return false;

	}
	public function update($data,$id,$lang)
	{
		
		$where = $this->pri_key." =".$id." and $this->lang_key= $lang";
		if($this->db->update($this->table,$data,$where))
			return true;
		
		return false;
	
	}
	
	
	
	public function info_form_id($id)
	{
		if(is_numeric($id) && $id !="")
		{
		$this->db->where($this->pri_key.' =',$id);
		$this->db->order_by("$this->lang_key");
		return $this->db->get($this->table)->result_array();
		}
		else
			return false;
	}
	
	public function get_title($id )
	{
		if(is_numeric($id) && $id !="")
		{
		$this->db->where($this->pri_key.' =',$id);
		$this->db->where($this->lang_key.' =',1);
		return $this->db->get($this->table)->row_array();
		}
		else
			return false;
		
	}
	
	
	

	public function list_data($num,$off)
	{
		$this->db->limit($off,$num);
		$this->db->where($this->lang_key.' =',1);
		$this->db->order_by($this->pri_key." DESC");
		if($this->db->count_all($this->table) >0)
			//return $this->db->get($this->table)->result_array();
			{
				return $this->db->get($this->table)->result_array();
			}
		return false;
	}
	// dem so record 
	function count_all()
	{
		return $this->db->count_all_results($this->table);
	}
	public function get_last_id()
	{
		$this->db->select($this->pri_key);
		$this->db->order_by($this->pri_key." DESC");
		return $this->db->get($this->table)->row_array();
	}
	
	
	


	





	function delete()

	{

		if (isset($_POST['checkbox1']))

		{

			foreach($_POST['checkbox1'] as $id) {

			//	$row = $this->info_from_id($id);

		

				//xoa file

		//		if ($row['avatar'] != 'null') unlink($row['avatar']);

		

				//xoa CSDL

			//	$sql = "DELETE FROM human_resources WHERE id=$id";
			if($id > 4)
			{
				$this->db->where($this->pri_key, $id);
				$this->db->delete($this->table); 
			}//$this->db->query($sql);

			}			

		}

	}



 






}//end model class





/* End of file mhumans.php */

/* Location: ./system/application/models/mhumans.php */

?>